import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import javax.swing.JFileChooser;

public class MyActionListener implements ActionListener {
	Graphics g;
	final int gridFitMeter = 100;
	BufferedImage img = null;
	JFileChooser fc = new JFileChooser();
	MyFrame parent;

	// In response to a button click:

	public MyActionListener(MyFrame p) {
		parent = p;
		fc = new JFileChooser();
		fc.setMultiSelectionEnabled(false);
		g = p.getGraphics();
	}

	@Override
	public void actionPerformed(ActionEvent act) {
		if(act.getSource().equals(parent.bOpenMap))
			openMap();
		if(act.getSource().equals(parent.bStart))
			startCutting();			
	}
	

	private void startCutting() {
		parent.start();
		
	}

	private void openMap() {
		int returnVal = fc.showOpenDialog(parent);
		if (returnVal == JFileChooser.APPROVE_OPTION){
			parent.tMapPath.setText(fc.getSelectedFile().getAbsolutePath());
			parent.mapChanged();
		}
		
	}
}
